package org.example.web;


import com.example.fanqie.entity.User;
import com.example.fanqie.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("admin")
public class adminDao {


    @Resource
    private UserMapper userMapper;

    @RequestMapping("add")
    public int addadmin( @RequestBody User user){

        int add = userMapper.insert(user);

        return add;
    }


    @RequestMapping("select")
    public List<User> selectadmin(  ){

        List<User> users = userMapper.selectadmin();
//        System.out.println(users);

        return users;
    }
    @RequestMapping("update")
    public int updateadmin( @RequestBody User user){

        int update = userMapper.updateById(user);

        return update;
    }

    @RequestMapping("delete")
    public int deleteadmin( @RequestBody User user){

        int delete = userMapper.updateById(user);

        return delete;
    }





}
